package com.hellobike.haxing.modules.wms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hellobike.haxing.modules.wms.dto.ExportPickKQDto;
import com.hellobike.haxing.modules.wms.dto.ExportPickZTDDto;
import com.hellobike.haxing.modules.wms.entity.PickHeader;
import com.hellobike.haxing.modules.wms.enums.DocTypeEnum;
import com.hellobike.haxing.modules.wms.enums.PickTypeEnum;
import com.hellobike.haxing.modules.wms.mapper.PickHeaderMapper;
import com.hellobike.haxing.modules.wms.service.IPickHeaderService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: t_wms_pick_header
 * @Author: haxing-boot
 * @Date: 2020-01-14
 * @Version: V1.0
 */
@Service
public class PickHeaderServiceImpl extends ServiceImpl<PickHeaderMapper, PickHeader> implements IPickHeaderService {

    @Override
    public boolean hasPick(Long docId, String docType) {
        PickHeader q = new PickHeader();
        q.setDocId(docId);
        q.setDocType(docType);
        QueryWrapper<PickHeader> queryWrapper = new QueryWrapper<>(q);
        return baseMapper.selectCount(queryWrapper) > 0;
    }

    @Override
    public PickHeader getZTDByDeliveryOrderHeaderId(Long orderHeaderId) {
        PickHeader q = new PickHeader();
        q.setDocId(orderHeaderId);
        q.setDocType(DocTypeEnum.DO.getValue());
        QueryWrapper<PickHeader> queryWrapper = new QueryWrapper<>(q);
        return baseMapper.selectOne(queryWrapper);
    }

    @Override
    public List<ExportPickKQDto> exportPickKQ(Long id) {
        return baseMapper.exportPickKQ(id);
    }

    @Override
    public List<ExportPickZTDDto> exportPickZTD(Long id) {
        return baseMapper.exportPickZTD(id);
    }
}
